# Link reference definitions
A link reference definition (opens new window) consists of a link label (opens new window), indented up to three spaces, followed by a colon (:), optional whitespace (opens new window) (including up to one line ending (opens new window)), a link destination (opens new window), optional whitespace (opens new window) (including up to one line ending (opens new window)), and an optional link title (opens new window), which if it is present must be separated from the link destination (opens new window)by whitespace (opens new window). No further non-whitespace characters (opens new window) may occur on the line.
A link reference definition (opens new window) does not correspond to a structural element of a document. Instead, it defines a label which can be used in reference links (opens new window) and reference-style images (opens new window) elsewhere in the document. Link reference definitions (opens new window) can come either before or after the links that use them.
Example 161
| Markdown | HTML | Demo |
|---|---|---|
|
|
Example 162
| Markdown | HTML | Demo |
|---|---|---|
|
|
Example 163
| Markdown | HTML | Demo |
|---|---|---|
|
|
Example 164
| Markdown | HTML | Demo |
|---|---|---|
|
|
The title may extend over multiple lines:
Example 165
| Markdown | HTML | Demo |
|---|---|---|
|
|
However, it may not contain a blank line (opens new window):
Example 166
| Markdown | HTML | Demo |
|---|---|---|
|
|
The title may be omitted:
Example 167
| Markdown | HTML | Demo |
|---|---|---|
|
|
The link destination may not be omitted:
Example 168
| Markdown | HTML | Demo |
|---|---|---|
|
|
However, an empty link destination may be specified using angle brackets:
Example 169
| Markdown | HTML | Demo |
|---|---|---|
|
|
The title must be separated from the link destination by whitespace:
Example 170
| Markdown | HTML | Demo |
|---|---|---|
|
|
Both title and destination can contain backslash escapes and literal backslashes:
Example 171
| Markdown | HTML | Demo |
|---|---|---|
|
|
A link can come before its corresponding definition:
Example 172
| Markdown | HTML | Demo |
|---|---|---|
|
|
If there are several matching definitions, the first one takes precedence:
Example 173
| Markdown | HTML | Demo |
|---|---|---|
|
|
As noted in the section on Links (opens new window), matching of labels is case-insensitive (see matches (opens new window)).
Example 174
| Markdown | HTML | Demo |
|---|---|---|
|
|
Example 175
| Markdown | HTML | Demo |
|---|---|---|
|
|
Here is a link reference definition with no corresponding link. It contributes nothing to the document.
Example 176
| Markdown | HTML | Demo |
|---|---|---|
|
|
Here is another one:
Example 177
| Markdown | HTML | Demo |
|---|---|---|
|
|
This is not a link reference definition, because there are non-whitespace characters (opens new window) after the title:
Example 178
| Markdown | HTML | Demo |
|---|---|---|
|
|
This is a link reference definition, but it has no title:
Example 179
| Markdown | HTML | Demo |
|---|---|---|
|
|
This is not a link reference definition, because it is indented four spaces:
Example 180
| Markdown | HTML | Demo |
|---|---|---|
|
|
This is not a link reference definition, because it occurs inside a code block:
Example 181
| Markdown | HTML | Demo |
|---|---|---|
|
|
A link reference definition (opens new window) cannot interrupt a paragraph.
Example 182
| Markdown | HTML | Demo |
|---|---|---|
|
|
However, it can directly follow other block elements, such as headings and thematic breaks, and it need not be followed by a blank line.
Example 183
| Markdown | HTML | Demo |
|---|---|---|
|
|
Example 184
| Markdown | HTML | Demo |
|---|---|---|
|
|
Example 185
| Markdown | HTML | Demo |
|---|---|---|
|
|
Several link reference definitions (opens new window) can occur one after another, without intervening blank lines.
Example 186
| Markdown | HTML | Demo |
|---|---|---|
|
|
Link reference definitions (opens new window) can occur inside block containers, like lists and block quotations. They affect the entire document, not just the container in which they are defined:
Example 187
| Markdown | HTML | Demo |
|---|---|---|
|
|
Whether something is a [link reference definition] is independent of whether the link reference it defines is used in the document. Thus, for example, the following document contains just a link reference definition, and no visible content:
Example 188
| Markdown | HTML | Demo |
|---|---|---|
|
|